﻿#include<stdio.h>
void RotateArray(int* a,int len)
{
    int temp = a[0];
    a[0] = a[len - 1];
    while (len - 2 > 0)
    {
        a[len - 1] = a[len - 2];
        len--;
    }
    a[1]=temp;
}
int minNumberInRotateArray(int* rotateArray, int rotateArrayLen)
{
    int i = 0;
    for (i = 1; i < rotateArrayLen; i++)//判断数组是否有递减数列
    {
        if (rotateArray[i - 1] > rotateArray[i])
            return rotateArray[i];//有则返回递减数列中的小值，即右边的值
    }
    return rotateArray[0];//没有递减数列，返回a[0]
}

int main()
{
    int a[] = { 0,1,2,3,4,5,5,6,7,9 };
    int len = sizeof(a) / sizeof(a[0]);
    int num = 3;
    for (int i = 0; i < num; i++)
    {
        RotateArray(a, len);
    }
    int min = minNumberInRotateArray(a, len);
    printf("%d \n", min);
    return 0;
}